var a = require("../../A4730AC3A71FB5DFC21562C4223CA4D1.js");

Page({
    data: {
        orderId: "",
        price: "",
        fromPage: "order"
    },
    onLoad: function(a) {
        this.setData({
            price: a.price,
            orderId: a.orderId,
            fromPage: a.from || "order"
        });
    },
    goback: function() {
        if ("activity" === this.data.fromPage) wx.navigateBack({
            delta: 1
        }); else {
            var a = getCurrentPages(), e = 1, t = !1, r = !0, i = !1, o = void 0;
            try {
                for (var n, d = a[Symbol.iterator](); !(r = (n = d.next()).done); r = !0) {
                    var c = n.value;
                    if ("pages/order/list" === c.route) {
                        t = !0, e = a.indexOf(c);
                        break;
                    }
                }
            } catch (a) {
                i = !0, o = a;
            } finally {
                try {
                    !r && d.return && d.return();
                } finally {
                    if (i) throw o;
                }
            }
            if (t) {
                var s = a.length - e - 1;
                wx.navigateBack({
                    delta: s
                });
            } else wx.redirectTo({
                url: "/pages/order/list"
            });
        }
    },
    tapPay: function() {
        var e = this;
        wx.showLoading({
            title: "正在支付",
            mask: !0
        }), a.post("/v2/order/product/payment", {
            order_id: this.data.orderId,
            pay_type: 2,
            pay_client: 2
        }).then(function(a) {
            if (wx.hideLoading(), 1001 === a.data.code) {
                getApp().globalData.isEditOrder = !0;
                var t = a.data.response.data;
                wx.requestPayment({
                    timeStamp: t.timeStamp,
                    nonceStr: t.nonceStr,
                    package: t.package,
                    signType: t.signType,
                    paySign: t.paySign,
                    success: function() {
                        "activity" === e.data.fromPage ? setTimeout(function() {
                            wx.navigateBack({
                                delta: 1
                            });
                        }, 200) : e.goback();
                    }
                });
            }
        }).catch(function() {
            wx.hideLoading();
        });
    }
});